package astudy;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Clone {

	public static void main(String[] args) {

		Date d = new Date();
		
		System.out.println(d.getTime());
		d.setHours(0);
		System.out.println(d.getTime());
		
//		ArrayList<BigDecimal> list = new ArrayList<BigDecimal>();
//		list.add(new BigDecimal(123));
//		list.add(new BigDecimal(456));
//		List<Foo> new_list = new ArrayList<Foo>();
//		for (Foo d: list) {
//			new_list.add((Foo)d.clone());
//		}
//		System.out.println(new_list);
//		for (Foo d: new_list) {
//			d.a = d.a + 10;
//		}
//		System.out.println(new_list);
//		System.out.println(list);
	}

	private static void testFoo() {
		ArrayList<Foo> list = new ArrayList<Foo>();
		list.add(new Foo(123));
		list.add(new Foo(456));
		List<Foo> new_list = new ArrayList<Foo>();
		for (Foo d: list) {
			new_list.add((Foo)d.clone());
		}
		System.out.println(new_list);
		for (Foo d: new_list) {
			d.a = d.a + 10;
		}
		System.out.println(new_list);
		System.out.println(list);
	}
	
	public static class Foo implements Cloneable {
		private int a;
		public Foo(int a) {
			this.a = a;
		}
		public String toString() {
			return "" + this.a;
		}
		public Object clone() {
			return new Foo(this.a);
		}
	}
}
